﻿#include "UnstackPlateWid.h"
#include "componentmanager.h"
#include "./unstackplate/unstackplatemanager.h"
#include "unstackplateinfo.h"

UnstackPlateWid::UnstackPlateWid(QWidget* parent)
	: QWidget(parent)
{
	ui.setupUi(this);
}

UnstackPlateWid::~UnstackPlateWid()
{}

bool UnstackPlateWid::Init()
{
	auto platem = dynamic_cast<UnstackPlateManager*>(component->GetComponent(Component::component_unstackPlate));
	if (platem == nullptr) {
		return false;
	}

	auto plates = platem->GetAllUnstackPlateName();
	if (plates.size() <= 0) {
		return false;
	}
	for (auto iter : plates) {
		auto obj = platem->GetPlateObject(iter);
		if (obj != nullptr) {
			auto temp = new UnstackPlateInfo(obj, this);
			ui.tabWidget->addTab(temp, iter);
		}
	}
	return true;
}
